package com.njmaomao.gj.pyot.domain.wechat.wechatapi.sandboxnew;

import com.njmaomao.gj.pyot.config.Bizs;
import com.njmaomao.gj.pyot.domain.wechat.PayConfig;
import com.thoughtworks.xstream.annotations.XStreamAlias;

/**
 * 获取仿真系统验签秘钥入参
 *
 * @author hh 2018-5-10
 * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_1
 */
@XStreamAlias("xml")
public class GetSignkeyReq {

    // 商户号 必填[是] 微信支付分配的微信商户号
    @XStreamAlias("mch_id")
    private String mchId;

    // 随机字符串 必填[是] 随机字符串，不长于32位
    @XStreamAlias("nonce_str")
    private String nonceStr;

    // 签名 必填[是] 签名值
    private String sign;

    public String getMchId() {
        return mchId;
    }

    public String getNonceStr() {
        return nonceStr;
    }

    public String getSign() {
        return sign;
    }

    public static GetSignkeyReq build(String mchId, PayConfig payConfig) {
        GetSignkeyReq getSignkeyReq = new GetSignkeyReq();
        getSignkeyReq.mchId = mchId;
        getSignkeyReq.nonceStr = Bizs.generateNonceStr();
        getSignkeyReq.sign = Bizs.getMd5Sign(getSignkeyReq, payConfig.getKey());
        return getSignkeyReq;
    }
}
